package com.rizzo.infrastructure.domain;

public enum TrendType {

	MIN("min"),
	MAX("max"),
	MEAN("mean"),
	DEVIATION("deviation"),
	HITS("hits"),
	ALL("all");

	private String prefix;

	TrendType(String prefix) {
		this.prefix = prefix;
	}

	public String getPrefix() {
		return prefix;
	}

	public static TrendType fromPrefix(String token) {
		for (TrendType c : TrendType.values()) {
			if (c.prefix.equals(token)) {
				return c;
			}
		}
		throw new IllegalArgumentException("'" + token + "' could not be converted to a TrendType!");
	}

	public static boolean isTrendType(String prefix) {
		for (TrendType c : TrendType.values()) {
			if (c.prefix.equals(prefix)) {
				return true;
			}
		}
		return false;
	}

}
